const TODO_KEY = 'todoList'

export function getId() {
    return Date.now() + Math.random().toString(16).substring(2, 6)
}

export function fetchData() {
    const todoList = localStorage.getItem(TODO_KEY)
    if(todoList) {
        return JSON.parse(todoList)
    } else {
        return []
    }
}

export function save(todos) {
    localStorage.setItem(TODO_KEY, JSON.stringify(todos))
}